import request from '@/utils/request'

// 1. 添加到购物车
// goodsId: 商品ID goodsNum: 购买数量 goodsSkuId: 商品规格ID
export const addToCartApi = (goodsId, goodsNum, goodsSkuId) => {
  return request.post('/cart/add', {
    goodsId,
    goodsNum,
    goodsSkuId
  })
}

// 2. 获取购物车商品总数
export const getCartTotalApi = () => {
  return request.get('/cart/total')
}

// 3. 获取购物车商品列表
export const getCartListApi = () => {
  return request.get('/cart/list')
}

// 4. 购物车商品更新
export const updateCartApi = (goodsId, goodsNum, goodsSkuId) => {
  return request.post('/cart/update', {
    goodsId,
    goodsNum,
    goodsSkuId
  })
}

// 5. 删除购物车商品
export const deleteCartGoodsApi = (cartIds) => {
  return request.post('/cart/clear', {
    cartIds
  })
}
